import Reflux from 'reflux';
import PageConst from './PageConst';
import Actions from './Actions';

import { Control } from 'react-keeper'
import update from 'react-addons-update';
import Utils from './../../../utils';
const { Cross_URL,JDPDF_URL} = require(`./../../../config/${ENV}.json`);
import moment from 'moment';
import DB from './../../../app/db';


export default Reflux.createStore({
  listenables: [Actions],
  data: {
    ...PageConst,
    //滚动组件
    infs: null,
    //查询到的日志
    rzls: [],
    //选中的日志
    currentObj: {},
    //选中工程
    currentEng: {},

    //搜索关键字
    keyword: '',
    //当前页数
    currentPage: 1,
    pageSize: 10,
    isUpload: false,
    lastPage: false,
    isStart: false,
    //本弹窗是否显示
    fullpage_show: false,
    jlrq:{},
    jlicon:{},
    pdfurl:'',
    jlurl:'',
    docId:'',
    printurl:'',
    //工程id
    engid:'',
    //条件搜索
    searchText:'',
    items: [],
    ParamValue :{code:"xxx",text:"123"},
  },



  //初始化方法
  onInit: function () {
    this.updateComponent();
  },

  initMode: function (params) {
    this.data.currentObj = update(this.data.currentObj, {$set: {}});
    this.updateComponent();
  },


  loadMode: function (params) {
    this.data.currentObj = update(this.data.currentObj,  {$set: params});
    this.data.pdfurl = JDPDF_URL+'web/viewer.html?file='+JDPDF_URL+this.data.currentObj.pdf+'%3FdocId%3D'+this.data.currentObj.id;


    /*this.onJlFetch();*/
    this.updateComponent();
  },



  onJlFetch: function () {


  },

  onKeyFetch: function (params) {

  },

  onAddPage(){

  },

  onJlrqChange: function (params) {

    this.updateComponent();
  },

  onjlrqClear: function (params) {

    this.updateComponent();
  },


  onFetch: function (params, cb) {
    let t = this;
    t.updateComponent();
    cb && cb(t.data);
  },

  updateComponent: function () {
    this.trigger(this.data);
  },

  getInitialState: function () {
    return this.data;
  }


});
